package com.example.test.gridview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;

import com.example.test.R;

public class GViewBActivity extends Activity implements OnItemClickListener {
	private String[] WORLDCUP2010 = new String[] { "Algeria", "Argentina",
			"Australia", "Brazil", "Cote d'Ivoire", "Cameroon", "Chile",
			"Costa Rica", "Denmark", "England", "France", "Germany", "Ghana",
			"Greece", "Honduras", "Italy", "Japan", "Netherlands",
			"New Zealand", "Nigeria", "North Korea", "Paraguay", "Portugal",
			"Serbia", "Slovakia", "Slovenia", "South Africa", "South Korea",
			"Spain", "Switzerland", "United States", "Uruguay" };
	private TextView textView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gridview1);
		textView = (TextView) findViewById(R.id.selectedGrid);
		GridView gridView = (GridView) findViewById(R.id.gridview1);
		gridView.setAdapter(new FunnyLookingAdapter(getApplicationContext(),
				android.R.layout.simple_list_item_1, WORLDCUP2010));
		gridView.setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		textView.setText(WORLDCUP2010[arg2]);

	}
}
